<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>封禁用户的调整</title>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/vue/vue.js"></script>
<link rel="stylesheet" type="text/css" href="js/ChatIndex.css">
<link rel="stylesheet" type="text/css" href="js/showGameChatpost.css">
<link rel="stylesheet" type="text/css" href="js/layui.css">
<link rel="stylesheet" type="text/css" href="js/laypage.css">
<link rel="stylesheet" type="text/css" href="bootstrap-3.3.7-dist/css/bootstrap.min.css">
<script type="text/javascript" src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script type="text/javascript">
	$(function(){
		$("#showAllGames").toggle(
			function(){ //展示所有的游戏
			$.ajax({
				url:'getAllGame.se',
				type:'post',
				dataType:'json',
				success:function(result){
					$.each(result,function(ind,ele){
						$("#showGame").append("<li align='center'><a onclick='adminGameChat("+ele.gameId+")' href='javascript:void(0)'>"+ele.gameName+"</a><li>");						
					})
					$("#hr2").html("<hr>");
				}
			})			
		},
		function(){
			$("#showGame").html("");
			$("#hr2").html("");
		}			
		);
		
		adminChat(1); //展示所有帖子
		
		$("#updateMore").click(function(){  //批量操作封禁用户
			var gameIdList="";
			$('input[name="chat"]:checked').each(function(){
				gameIdList=$(this).val()+" "+gameIdList;
			})
		     var re= confirm("确定要批量解封吗？");
			if(re){
				$.ajax({
					url:'adminUpdateMoreStopChat.se',  
					type:'post',
					data:{gameIdList:gameIdList},
					dataType:'json',
					
				})
			}
		
			 window.location.reload(); //刷新当前页面
		});
		
		
		$("#deleteMore").click(function(){  //批量删除帖子
			var postIdList="";
			$('input[name="chat"]:checked').each(function(){
				postIdList=$(this).val()+" "+postIdList;
			})
			$.ajax({
				url:'adminDeleteMoreChat.se',
				type:'post',
				data:{postIdList:postIdList},
				dataType:'json',
				
			})
			// window.location.reload(); //刷新当前页面
		});
		
		$("#search").click(function(){   //通过搜索来查找帖子
			
			  
			adminSearchChat(1);
			
		})
		
	})

		function jiefeng(obj){  //解封帖子
		//alert("111");
			var id= $(obj).parent().siblings().eq(0).children("input").val();
			//alert("确定解封吗？");
			 var re= confirm("确定要解封吗");
			 if(re){
				 $.ajax({
						url:'adminUpdateStopChat.se',
						type:'post',
						data:{postId:id},
					})
			 }
			
			 window.location.reload(); //刷新当前页面
		}
		
		function deleteChat(obj){   //删除帖子
			var id= $(obj).parent().siblings().eq(0).children("input").val();
			var re=  confirm("确定要删除吗，删除之后数据将不复存在");
			if(re){
				$.ajax({
					url:'adminDeleteChat.se',
					type:'post',
					data:{postId:id},
				})
			}
			
			window.location.reload(); //刷新当前页面
		}
		
		function adminGameChat(gameId){// 点击游戏名称展示
			//alert(gameId);
		
			adminGameChat(gameId,1);
			
		}
	

</script>
</head>
<body>

  <div id="body07">
  <nav class="navbar navbar-inverse" role="navigation">
     </nav>
     <div id="adminChatHead">      
        <button class="layui-btn layui-btn-normal" style="margin-left:50px" id="showAllGames">所有游戏</button>
        <input type="text" id="searchGame" style="height:36px;margin-left:100px"  placeholder="游戏">  <input type="text" id="searchChatPost" style="height:36px"  placeholder="帖子">
        <input type="text" id="searchStartTime" style="height:36px"  placeholder="yyyy-MM-dd HH:mm:ss"><!-- -<input type="text" id="searchOverTime" style="height:36px"  placeholder="yyyy-MM-dd HH:mm:ss"> -->
        <button class="layui-btn layui-btn-normal layui-btn-radius" id="search">搜索</button>
        <hr>
        <ul id="showGame" style="none">  </ul>
     </div>
     <div id="hr2"></div>
     <div id="adminChatBody">
         <table style="width:100%">
         <tr  v-for="li in adminChatList" style="height:30px;border-bottom-width: thin;border-bottom-style: ridge;">
         <td style="width:3%"><input type="checkbox" name="chat" :value="li.postId">  </td>
         <td style="width:30%">{{li.postTitle}}</td><td>{{li.postContent}}</td>
         <td style="width:10%"><button class="layui-btn layui-btn-xs" onclick="jiefeng(this)">解封</button><button class="layui-btn layui-btn-xs" onclick="deleteChat(this)">删除</button></td>
          </tr>
         </table>

     <div id="lay" style="margin-top:20px"> </div> 
     <div style="margin-top:30px;margin-left:20px;"> <button class="layui-btn layui-btn-danger" id="deleteMore">批量删除</button> <button class="layui-btn layui-btn-danger" id="updateMore">批量解封</button></div>
     </div>
     <script type="text/javascript" src="js/laypage.js"></script>
     <script type="text/javascript">
      var adminSearchChat=function(currentPage){
    	  var gameName=$("#searchGame").val();
	  		var postTitle=$("#searchChatPost").val();
	  		var postTime=$("#searchStartTime").val();
	  		/* var overTime=$("#searchOverTime").val(); */
    	  $.ajax({
  			url:'adminSearchStopChat.se',
  			type:'post',
  			data:{gameName:gameName,postTitle:postTitle,postTime:postTime,currentPage:currentPage},
  			dataType:'json',
  			success:function(result){
  				console.log(result);
  				vue.adminChatList=result.cpList;
  				
  				laypage({
  				  cont:$("#lay"),
  				  pages:result.pages,
  				  curr:currentPage,
  				  groups:3,
  				  skip:true,
  				  jump:function(obj,first){
  					  if(!first){
  						adminSearchChat(obj.curr);
  					  }  					  
  				  }
  			  })
  			}
  		})
      }
     
     
     
     var adminGameChat=function(gameId,currentPage){
 		$.ajax({
 			url:'AdminAllStopChat.se',
 			type:'post',
 			data:{'gameId':gameId,'currentPage':currentPage},
 			dataType:'json',
 		success:function(result){
 			vue.adminChatList=result.adminChatList;
			  
			  laypage({
				  cont:$("#lay"),
				  pages:result.pages,
				  curr:currentPage,
				  groups:3,
				  skip:true,
				  jump:function(obj,first){
					  if(!first){
						  adminChat(gameId,obj.curr);
					  }  					  
				  }
			  })
 		}
 		})
 	}
     
     
     
      var adminChat=function(currentPage){
    	  $.ajax({
    		  url:'AdminAllStopChat.se',
    		  type:'post',
    		  data:{currentPage:currentPage},
    		  dataType:'json',
    		  success:function(result){
    			  vue.adminChatList=result.adminChatList;
    			  
    			  laypage({
    				  cont:$("#lay"),
    				  pages:result.pages,
    				  curr:currentPage,
    				  groups:3,
    				  skip:true,
    				  jump:function(obj,first){
    					  if(!first){
    						  adminChat(obj.curr);
    					  }  					  
    				  }
    			  })
    		  }
    	  })
      }
     
      var vue =new Vue({
    	  el:'#adminChatBody',
    	  data:{
    		  adminChatList:"",
    	  }
      })
     </script>
 
  
  </div>
  
</body>
</html>